home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / imagine / extras / tools / iiutilities / stageshift < prev    next >
Text File  |  1995-01-14  |  3KB  |  92 lines

  1. /*\
  2.  *   This script will add a specified number of empty frames to the
  3.  *   beginning of an Imagine staging file.  Should work with v3.1+
  4.  *
  5.  *   Usage: StageShift <stageFileName> <frames>
  6.  *
  7.  *   Notes:
  8.  *     Each object is given a line of its own in the output.  A "." is
  9.  *     displayed for each timeline bar that is modified.
  10.  *     This is not very usefull unless you have the ISL language by
  11.  *     John Grieggs to join multiple projects together.  I am not
  12.  *     sure if it works since I don't have a copy.  Beware of changing
  13.  *     camera sizes and such in one project, and using the defaults in
  14.  *     another.  If you join them together, any project with defaults
  15.  *     will inherit the valuse of the previous project.  So watch out.
  16.  *     The former stage file will be renamed to <filename>.old and saved.
  17.  *
  18.  *  V1.0 Jan-14-94
  19.  *  IanSmith@moose.erie.net
  20.  *
  21. \*/
  22.  
  23. Numeric Digits 14                    /* Need at least 12 to handle 32 bits */
  24. Parse Arg FileName Change .
  25. If Change="" Then Do
  26.  Say "Usage: StageShift <stageFileName> <frames>"
  27.  Say "       More help can be found in the header of this file."
  28.  Exit
  29. End
  30.  
  31. MaxFrames=0
  32. Temp="Temp$Stage."||Date(D)||Time(S)               /* Create temp filename */
  33. Address Command 'Delete >NIL:' FileName||".Old"    /* Erase backup file */
  34. If Open(Out,Temp,"W")=0 Then Do
  35.  Say "Can't open temp staging file!"
  36.  Exit
  37. End
  38. If Open(In,FileName,"R")=0 Then Do
  39.  Say "Can't find '"FileName"' to open!"
  40.  Exit
  41. End
  42. Call Open(Text,"*","W")
  43. Call WriteCH(Text,"Shifting '"||FileName||"' forward "||Change||" frames.")
  44. Call ParseStaging(C2D(SubStr(ReadWrite(In,12),5,4)))
  45. Call WriteLN(Text,"") Close(In) Close(Out) Close(Text)
  46. Address Command 'Rename' FileName 'To' FileName||".Old"
  47. Address Command 'Rename' Temp 'To' FileName
  48.  
  49. Exit
  50.  
  51. ParseStaging: PROCEDURE EXPOSE Change MaxFrames
  52.  Parse Arg MaxSize                             /* Recursive Function     */
  53.  TotalSize=4; New=0
  54.  Do Until TotalSize>=MaxSize                   /* Read MaxSize Bytes     */
  55.   LastName=Name
  56.   Name=ReadWrite(In,4)
  57.   If Name~=LastName Then New=0
  58.   Size=C2D(ReadWrite(In,4))
  59.   If Size//2=1 Then Size=Size+1                /* Add pad byte if needed */
  60.   If Name="ISTG" | Name="SOBJ" Then Do
  61.    TotalSize=TotalSize+ParseStaging(Size)+8    /* Parse into these hunks */
  62.    Iterate
  63.   End
  64.   TotalSize=TotalSize+Size+8                   /* Add SIZE and NAME length */
  65.   If Name="NAME" Then
  66.    Call WriteCH(Text,'0A'x||"  "||ReadWrite(In,Size))
  67.   Else If Name="MAXF" Then Do
  68.    MaxFrames=C2D(ReadCH(In,Size))
  69.    Call WriteCH(Out,Right(D2C(MaxFrames+Change),2,'00'x))
  70.   End; Else If Index("LOOP-NAME-STGF-LYR0", Name)=0 Then Do
  71.    Call WriteCH(Text,".")
  72.    Buffer=ReadCH(In,Size)
  73.    StartF=C2D(SubStr(Buffer,3,2))
  74.    EndF=C2D(SubStr(Buffer,5,2))
  75.    If (StartF>0 & StartF<=MaxFrames & EndF>0 & EndF<=MaxFrames & StartF<=EndF) Then Do
  76.     Buffer=Overlay(Right(D2C(StartF+Change),2,'00'x),Buffer,3)
  77.     Buffer=Overlay(Right(D2C(EndF+Change),2,'00'x),Buffer,5)
  78.    End; Else Do
  79.     Say "Hunk" Name "is not a valid timeline!"
  80.    End
  81.    Call WriteCH(Out,Buffer)
  82.   End; Else
  83.    Call ReadWrite(In,Size)
  84.  End
  85. Return TotalSize
  86.  
  87. ReadWrite:
  88.  Parse Arg FileHandle , Bytes .
  89.  RWBuffer=ReadCH(FileHandle, Bytes)
  90.  Call WriteCH(Out,RWBuffer)
  91. Return RWBuffer
  92.